package demo2;

// LightOffCommand.java
public class LightOffCommand implements Command {
    private Light light;

    public LightOffCommand(Light light) {
        this.light = light;
    }

    @Override
    public void execute() {
        light.off();  // 调用灯的关闭方法
    }

    @Override
    public void undo() {
        light.on();   // 撤销就是开灯
    }
}
